package com.atguigu.lease.admin.controller;

import com.atguigu.lease.admin.service.RoomInfoService;
import com.atguigu.lease.model.dto.RoomItemQueryDto;
import com.atguigu.lease.model.dto.RoomSubmitDto;
import com.atguigu.lease.model.result.Response;
import com.atguigu.lease.model.vo.RoomItemVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Tag(name = "房间信息管理模块")
@RestController
@RequestMapping("/admin/room")
public class RoomInfoController {
    @Autowired
    RoomInfoService roomInfoService;

    @Operation(summary = "1、条件查询房间分页数据列表")
    @GetMapping("/pageItem")
    public Response<Page<RoomItemVo>> pageItem(RoomItemQueryDto queryDto){
        Page<RoomItemVo> page = roomInfoService.pageItem(queryDto);
        return Response.ok(page);
    }

    @Operation(summary = "2、新增或更新房间信息")
    @PostMapping("saveOrUpdate")
    public Response saveOrUpdate(@RequestBody RoomSubmitDto roomSubmitDto) {
        roomInfoService.saveOrUpdateRoomSubmitDto(roomSubmitDto);
        return Response.ok(null);
    }
}
